﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    
                    xmlns:local="clr-namespace:MRU.View"
                    xmlns:hyperl="clr-namespace:Hyperlink"                    
                    >

  <!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        Checkbox style for pin visual
        Original source of animation (is replaced with own XAML image)
        http://stackoverflow.com/questions/7459642/how-do-i-create-a-wpf-checkbox-control-template-in-xaml-with-the-following-requi
      -->
  <Style TargetType="{x:Type local:PinnableCheckbox}">
    <Setter Property="SnapsToDevicePixels" Value="true" />
    <!-- Setter Property="OverridesDefaultStyle" Value="true" -->
    <Setter Property="FocusVisualStyle" Value="{DynamicResource CheckBoxFocusVisual}" />
    <Setter Property="LayoutTransform">
      <Setter.Value>
        <ScaleTransform CenterX="50"  CenterY="50" ScaleX=".15" ScaleY=".15"/>
      </Setter.Value>
    </Setter>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type CheckBox}">
          <BulletDecorator Background="Transparent">
            <BulletDecorator.Bullet>

              <Grid>
                <Canvas Width="100" Height="100" x:Name="NoCheckMark" Opacity="0" Visibility="Visible">
                  <Canvas.LayoutTransform>
                    <RotateTransform Angle="90" />
                  </Canvas.LayoutTransform>

                    <Canvas Width="300" Height="300" Canvas.Left="0" Canvas.Top="0">
                    <Canvas Canvas.Top="15">
                      <!-- Needle -->
                      <Path VerticalAlignment="Center" Fill="Black">
                        <Path.Data>
                          <PathGeometry>
                            <PathGeometry.Figures>
                              <PathFigureCollection>
                                <PathFigure IsClosed="True" StartPoint="0,0">
                                  <PathFigure.Segments>
                                    <PathSegmentCollection>
                                      <LineSegment Point="45,50" />
                                      <LineSegment Point="45,85" />
                                      <LineSegment Point="55,95" />
                                      <LineSegment Point="55,50" />
                                      <LineSegment Point="45,50" />
                                    </PathSegmentCollection>
                                  </PathFigure.Segments>
                                </PathFigure>
                              </PathFigureCollection>
                            </PathGeometry.Figures>
                          </PathGeometry>
                        </Path.Data>
                      </Path>

                      <Line X1="45" Y1="50" X2="45" Y2="85" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                      <Line X1="45" Y1="85" X2="55" Y2="95" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                      <Line X2="55" Y2="95" X1="55" Y1="50" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                      <!-- Line X1="55" Y1="50" X2="45" Y2="50" Stroke="White" Opacity="0.5" StrokeThickness="3" / -->
                      <!-- Needle -->

                      <Path VerticalAlignment="Center" Fill="Black">
                        <Path.Data>
                          <PathGeometry>
                            <PathGeometry.Figures>
                              <PathFigureCollection>
                                <PathFigure IsClosed="True" StartPoint="0,0">
                                  <PathFigure.Segments>
                                    <PathSegmentCollection>
                                      <LineSegment Point=" 5,50" />
                                      <LineSegment Point="95,50" />
                                      <LineSegment Point="85,40" />
                                      <LineSegment Point="15,40" />
                                      <LineSegment Point=" 5,50" />
                                    </PathSegmentCollection>
                                  </PathFigure.Segments>
                                </PathFigure>
                              </PathFigureCollection>
                            </PathGeometry.Figures>
                          </PathGeometry>
                        </Path.Data>
                      </Path>

                      <Line X1="5"  Y1="50" X2="95" Y2="50" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                      <Line X1="95" Y1="50" X2="85" Y2="40" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                      <Line X2="85" Y2="40" X1="15" Y1="40" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                      <Line X1="15" Y1="40" X2="5"  Y2="50" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                    </Canvas>

                    <Path VerticalAlignment="Center" Fill="Black">
                      <Path.Data>
                        <PathGeometry>
                          <PathGeometry.Figures>
                            <PathFigureCollection>
                              <PathFigure IsClosed="True" StartPoint="0,0">
                                <PathFigure.Segments>
                                  <PathSegmentCollection>
                                    <LineSegment Point="25,55" />
                                    <LineSegment Point="75,55" />
                                    <LineSegment Point="75,10" />
                                    <LineSegment Point="25,10" />
                                    <LineSegment Point="25,55" />
                                  </PathSegmentCollection>
                                </PathFigure.Segments>
                              </PathFigure>
                            </PathFigureCollection>
                          </PathGeometry.Figures>
                        </PathGeometry>
                      </Path.Data>
                    </Path>

                    <!-- Line X1="25" Y1="55" X2="75" Y2="55" Stroke="Yellow" Opacity="0.5" StrokeThickness="3" / -->
                    <Line X1="75" Y1="55" X2="75" Y2="10" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                    <Line X2="75" Y2="10" X1="25" Y1="10" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                    <Line X1="25" Y1="10" X2="25" Y2="55" Stroke="White" Opacity="0.5" StrokeThickness="3" />

                  </Canvas>


                </Canvas>

                <Canvas Width="100" Height="100" x:Name="CheckMark">
                  <!-- Needle Pin in pined mode XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -->
                  <!-- Canvas.LayoutTransform>
  		                                      <ScaleTransform CenterX="50" CenterY="50" ScaleX=".15" ScaleY=".15" />
  	                                          </Canvas.LayoutTransform -->
                  <!-- Border BorderBrush="Black" BorderThickness="1" Width ="100" Height="100" / -->

                  <Canvas Width="300" Height="300" Canvas.Left="0" Canvas.Top="0">
                    <Canvas Canvas.Top="15">
                      <!-- Needle -->
                      <Path VerticalAlignment="Center" Fill="Black">
                        <Path.Data>
                          <PathGeometry>
                            <PathGeometry.Figures>
                              <PathFigureCollection>
                                <PathFigure IsClosed="True" StartPoint="0,0">
                                  <PathFigure.Segments>
                                    <PathSegmentCollection>
                                      <LineSegment Point="45,50" />
                                      <LineSegment Point="45,85" />
                                      <LineSegment Point="55,95" />
                                      <LineSegment Point="55,50" />
                                      <LineSegment Point="45,50" />
                                    </PathSegmentCollection>
                                  </PathFigure.Segments>
                                </PathFigure>
                              </PathFigureCollection>
                            </PathGeometry.Figures>
                          </PathGeometry>
                        </Path.Data>
                      </Path>

                      <Line X1="45" Y1="50" X2="45" Y2="85" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                      <Line X1="45" Y1="85" X2="55" Y2="95" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                      <Line X2="55" Y2="95" X1="55" Y1="50" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                      <!-- Line X1="55" Y1="50" X2="45" Y2="50" Stroke="White" Opacity="0.5" StrokeThickness="3" / -->
                      <!-- Needle -->

                      <Path VerticalAlignment="Center" Fill="Black">
                        <Path.Data>
                          <PathGeometry>
                            <PathGeometry.Figures>
                              <PathFigureCollection>
                                <PathFigure IsClosed="True" StartPoint="0,0">
                                  <PathFigure.Segments>
                                    <PathSegmentCollection>
                                      <LineSegment Point=" 5,50" />
                                      <LineSegment Point="95,50" />
                                      <LineSegment Point="85,40" />
                                      <LineSegment Point="15,40" />
                                      <LineSegment Point=" 5,50" />
                                    </PathSegmentCollection>
                                  </PathFigure.Segments>
                                </PathFigure>
                              </PathFigureCollection>
                            </PathGeometry.Figures>
                          </PathGeometry>
                        </Path.Data>
                      </Path>

                      <Line X1="5"  Y1="50" X2="95" Y2="50" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                      <Line X1="95" Y1="50" X2="85" Y2="40" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                      <Line X2="85" Y2="40" X1="15" Y1="40" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                      <Line X1="15" Y1="40" X2="5"  Y2="50" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                    </Canvas>

                    <Path VerticalAlignment="Center" Fill="Black">
                      <Path.Data>
                        <PathGeometry>
                          <PathGeometry.Figures>
                            <PathFigureCollection>
                              <PathFigure IsClosed="True" StartPoint="0,0">
                                <PathFigure.Segments>
                                  <PathSegmentCollection>
                                    <LineSegment Point="25,55" />
                                    <LineSegment Point="75,55" />
                                    <LineSegment Point="75,10" />
                                    <LineSegment Point="25,10" />
                                    <LineSegment Point="25,55" />
                                  </PathSegmentCollection>
                                </PathFigure.Segments>
                              </PathFigure>
                            </PathFigureCollection>
                          </PathGeometry.Figures>
                        </PathGeometry>
                      </Path.Data>
                    </Path>

                    <!-- Line X1="25" Y1="55" X2="75" Y2="55" Stroke="Yellow" Opacity="0.5" StrokeThickness="3" / -->
                    <Line X1="75" Y1="55" X2="75" Y2="10" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                    <Line X2="75" Y2="10" X1="25" Y1="10" Stroke="White" Opacity="0.5" StrokeThickness="3" />
                    <Line X1="25" Y1="10" X2="25" Y2="55" Stroke="White" Opacity="0.5" StrokeThickness="3" />

                  </Canvas>

                </Canvas>
              </Grid>

            </BulletDecorator.Bullet>
          </BulletDecorator>

          <ControlTemplate.Triggers>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <!-- Condition Property="IsMouseOver" Value="True"/ -->
                <Condition Property="IsChecked" Value="False"/>
              </MultiTrigger.Conditions>

              <MultiTrigger.EnterActions>
                <BeginStoryboard>
                  <Storyboard>
                    <DoubleAnimation Storyboard.TargetProperty="Opacity" Storyboard.TargetName="NoCheckMark" To="0.3" Duration="0:0:0.1"/>
                  </Storyboard>
                </BeginStoryboard>
              </MultiTrigger.EnterActions>
              <MultiTrigger.ExitActions>
                <BeginStoryboard>
                  <Storyboard>
                    <DoubleAnimation Storyboard.TargetProperty="Opacity" Storyboard.TargetName="NoCheckMark" To="0" Duration="0:0:0.1"/>
                  </Storyboard>
                </BeginStoryboard>
              </MultiTrigger.ExitActions>

            </MultiTrigger>

            <Trigger Property="IsChecked" Value="True">
              <!-- Setter TargetName="CheckBorder" Property="Opacity" Value="1"/ -->
              <Setter TargetName="CheckMark" Property="Opacity" Value="1"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="False">
              <!-- Setter TargetName="CheckBorder" Property="Opacity" Value="0"/ -->
              <Setter TargetName="CheckMark" Property="Opacity" Value="0"/>
            </Trigger>

          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style TargetType="{x:Type local:PinableListViewItem}">
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="Padding" Value="1" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
    <!-- This is required for the PathTrimmingTextBlock -->
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="ListViewItem">
          <Border Name="ListemBackgroundBorder"
                  Padding="3"
                  BorderBrush="Transparent"
                  BorderThickness="1"
                  CornerRadius="3"
                  SnapsToDevicePixels="true"
                  Background="Transparent">
            <GridViewRowPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
          </Border>
          <!-- ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter TargetName="ListemBackgroundBorder" Property="Background" Value="{StaticResource ListViewItemMouseOverGradient}"/>
              <Setter TargetName="ListemBackgroundBorder" Property="BorderBrush" Value="{StaticResource ListViewItemMouseOverBorder}" />
              <Setter TargetName="ListemBackgroundBorder" Property="BorderThickness" Value="1" />
            </Trigger>
            <!- Trigger Property="IsSelected" Value="true">
              <Setter TargetName="Border" Property="Background" Value="Black"/>
            </Trigger ->
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Foreground" Value="{StaticResource PinableListViewForegroundDisabled}"/>
            </Trigger>
          </ControlTemplate.Triggers -->
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style TargetType="{x:Type local:PinableListView}">
    <Setter Property="SnapsToDevicePixels" Value="True"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type local:PinableListView}">
          <Border Padding="0"
                  BorderThickness="0"
                  BorderBrush="Transparent"
                  
                  Name="Bd"
                  SnapsToDevicePixels="True">
            <!-- Background="{StaticResource PinableListViewBackground}" -->
            <ScrollViewer Padding="0" Focusable="False">
              <ItemsPresenter SnapsToDevicePixels="True" />
            </ScrollViewer>
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

</ResourceDictionary>